/**
 * 
 */
package com.eagle.coders.security.beans;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 * @author Anees
 *
 */
@Entity
@Table(name ="eagle_actions")
@SequenceGenerator(name="action_gen_seq", sequenceName="eagle_gen_seq")
public class ActionBean implements Serializable {

	/**
	 * 
	 * @author Anees
	 *
	 */
	public enum ActionType {
		
		CREATE("C"), UPDATE("U"), DELETE("D");
		
		private String string;
		
		private ActionType(final String string){
			this.string = string;
		}
		
		public String getValue(){
			return this.string;
		}
		
	}
	private static final long serialVersionUID = 1L;

	private Integer id;
	
	private FunctionsBean function;
	
	private String actionType;
	
	private String description;

	/**
	 * @return the id
	 */
	@Id
	@GeneratedValue(generator="action_gen_seq", strategy=GenerationType.SEQUENCE)
	public Integer getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 * @return the function
	 */
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinColumn(name="function_cd", referencedColumnName = "id")
	public FunctionsBean getFunction() {
		return function;
	}

	/**
	 * @param function the function to set
	 */
	public void setFunction(FunctionsBean function) {
		this.function = function;
	}

	/**
	 * @return the actionType
	 */
	@Column(name = "action_type")
	@Enumerated(EnumType.STRING)
	public String getActionType() {
		return actionType;
	}

	/**
	 * @param actionType the actionType to set
	 */
	public void setActionType(String actionType) {
		this.actionType = actionType;
	}

	/**
	 * @return the description
	 */
	@Column(name = "description", length = 100)
	public String getDescription() {
		return description;
	}

	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}
}
